package com.lb.sentinelproject.web;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.lb.sentinelproject.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @version 1.0
 * @Author: Edward
 * @Date: 2021/1/21 11:03
 * @Description:
 */
@Slf4j
@RestController
@RequestMapping("/sen")
public class HelloController {

    @RequestMapping("/hello")
    public String hello() {
        return "success";
    }

    @GetMapping("/hot")
    @SentinelResource("hot")
    public R hot(
            @RequestParam(value = "num1", required = false) Integer num1,
            @RequestParam(value = "num2", required = false) Integer num2) {
        log.info("num1:{}, num2:{}", num1, num2);
        return R.ok();
    }
}
